/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.core.service;

import com.intelligent.ispc.core.dto.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Map;

/**
 * For project biz, this service supports all biz logic methods.
 * <p>
 * Created by Administrator on 2015/10/20.
 */
public interface ProjectService {

    /**
     * Save the project.
     *
     * @param parameDto
     */
    void saveProject(ProjectConfigureParameDto parameDto);

    /**
     * Update the project.
     *
     * @param project
     */
    void updateProject(ProjectDto project);

    /**
     * Delete the project with id.
     *
     * @param id
     */
    void deleteProject(String id);

    /**
     * Find project by provided id.
     *
     * @param id
     * @return the project dto.
     */
    ProjectDto findById(String id);

    /**
     * Find project by code.
     *
     * @param code
     * @return the project dto
     */
    ProjectDto findByCode(String code);

    /**
     * Find project by code.
     *
     * @param name
     * @return the project dto
     */
    ProjectDto findByName(String name);

    /**
     * Find all projects.
     *
     * @return the list of project dto
     */
    List<ProjectDto> findAllProjects();


    /**
     * Searching project by provided parameters.
     *
     * @param searchParams
     * @return the list of project dto.
     */
    List<ProjectDto> searchProject(Map<String, Object> searchParams);


    /**
     * Searching project by provided parameters with pageable data.
     *
     * @param searchParams
     * @param pageRequest
     * @return the page object for project dto.
     */
    Page<ProjectDto> searchProject(Map<String, Object> searchParams, Pageable pageRequest);

    /**
     * Find the CP Warning Rules by project ID, fetch all rules details.
     *
     * @param projectId
     * @return the list of CPWarningRuleDto
     */
    Page<CPWarningRuleDto> findCpWarningRulesByProject(String projectId, Pageable pageable);

    /**
     * Find the Control Chart Warning Rules by project ID, fetch all rules details.
     *
     * @param projectId
     * @return the list of ControlChartWarningRuleDto
     */
    Page<ControlChartWarningRuleDto> findControlChartWarningRuleByProject(String projectId, Pageable pageable);

    /**
     * Find the PSAttributeService by project ID
     *
     * @param projectId
     * @return the list of PSAttributeDto
     */
    Page<PSAttributeDto> findPSAttributeByProject(String projectId, Pageable pageable);

    /**
     * Find the PSGRRDto by project ID
     *
     * @param projectId
     * @return the PSGRRDto
     */
    PSGRRDto findPSGRRByProject(String projectId);

    /**
     * Find the PSAttributeService by project ID
     *
     * @param projectId
     * @return the list of PSAttributeDto
     */
    List<PSAttributeDto> findPSAttributeByProject(String projectId);

    /**
     * search the default control chart warning rules from data dictionary.
     *
     * @return the list of ControlChartWarning
     */
    List<ControlChartWarningRuleDto> findDefaultControlChartWarningRuleDto();

    /**
     * search the default CPWarning from data dictionary.
     *
     * @return the list of CPWarning
     */
    List<CPWarningRuleDto> findDefaultCPWarningRuleDto();

    /**
     * search the default PSAttributeService from data dictionary.
     *
     * @return the list of PSAttributeService
     */
    List<PSAttributeDto> findDefaultPSAttributeDto();

    /**
     * Find code whether exists
     *
     * @param code
     */
    void isCode(String code);

    /**
     * Find name whether exists
     *
     * @param name
     */
    void isName(String name);

    /**
     * Find the StatisticAnalysis Parameters by project ID, fetch all params details.
     *
     * @param projectId
     * @return the list of StatisticAnalysisParameterDto
     */
    List<StatisticAnalysisParameterDto> findStatisticAnalysisParameterByProjectId(String projectId);

    /**
     * Update the StatisticAnalysis Parameters by statisticAnalysisParameterDto.
     *
     * @param statisticAnalysisParameterDto
     */
    void updateStatisticAnalysisParameter(StatisticAnalysisParameterDto statisticAnalysisParameterDto) throws Exception;

    /**
     * Update the CP Warning Rules by cpWarningRuleDto.
     *
     * @param cpWarningRuleDto
     */
    void updateCPWarningRule(CPWarningRuleDto cpWarningRuleDto) throws Exception;

    /**
     * Update the Control Chart Warning Rules by controlChartWarningRuleDto.
     *
     * @param controlChartWarningRuleDto
     */
    void updateControlChartWarningRule(ControlChartWarningRuleDto controlChartWarningRuleDto) throws Exception;

    /**
     * Update the PSAttributeService by psAttributeDto.
     *
     * @param psAttributeDto
     */
    void updatePSAttribute(PSAttributeDto psAttributeDto);

    /**
     * Update the psGRRDto by psAttributeDao.
     *
     * @param psGRRDto
     */
    void updatePSGRR(PSGRRDto psGRRDto);

    /**
     * Add the Control Chart Warning Rules by controlChartWarningRuleDto.
     *
     * @param controlChartWarningRuleDto
     */
    void addControlChartWarningRule(ControlChartWarningRuleDto controlChartWarningRuleDto);

    /**
     * Add the CP Warning Rules by cpWarningRuleDto.
     *
     * @param cpWarningRuleDto
     */
    void addCPWarningRule(CPWarningRuleDto cpWarningRuleDto);

    /**
     * Add the psAttributeDto by psAttributeDao
     *
     * @param psAttributeDto
     */
    void addPSAttribute(PSAttributeDto psAttributeDto);

    /**
     * Add the psGRRDto by psGRRDao
     *
     * @param psGRRDto
     */
    void addPSGRR(PSGRRDto psGRRDto);

    /**
     * Delete the PSAttributeService by psaid
     *
     * @param psaid
     */
    void deletePSAttribute(String psaid);

    /**
     * Find project by code or name.
     *
     * @param code
     * @param name
     * @param id
     * @return the project dto
     */
    void checkNameOrCode(Long id, String name, String code);

}
